function [] = estimation_providerAdoptions(runId);

%%% Add paths
addpath('../model_funcs');
addpath('../model_funcs/dim_specific_funcs/dim2');
addpath('../general_funcs');

%%%%% Read config to get runFolder
config = getConfig_providerAdoptions(runId);
modelId = config.modelId;
runFolder = config.runFolder;

%%% Get input/output files
runDataFile = sprintf('%s/runData.mat', runFolder);
outputMatFile = sprintf('%s/results.mat', runFolder);
outputCSVFile = sprintf('%s/results.csv', runFolder);

%%% Load data
load(runDataFile);
NumParams = data.dims.NumParams;
paramNames = get_param_names_providerAdoptions(data);

%%% Define starting point params0
params0 = zeros(NumParams, 1);

%%% Display initial params
disp('========== INITIAL PARAMETER VALUES ==========');
myTable = array2table(params0);
myTable.Properties.RowNames = paramNames; myTable.Properties.VariableNames = {'StartingValue'};
disp(myTable);

%%% Launch estimation
data.LL_offset = 0; % Approximation to continuous-time mode --> no need for y! in denominator

% Estimation in one shot
if config.modelId ~= 3
	[params_hat, covMat, params_ses, modelFits] = estimate_model(modelId, data, params0);
else
	% Estimation by blocks
	[params_hat, covMat, params_ses, modelFits] = estimate_model_by_blocks(modelId, data, 100, params0);
end

%%% Display results
disp('========== ESTIMATES ==========');
myTable = reportSubmodelResults(paramNames, params_hat, params_ses, modelFits);
disp(myTable);

%%% Output results to files
save(outputMatFile, 'params_hat', 'params_ses', 'covMat', 'myTable', 'modelFits', '-v7.3');

% Keep 2 decimal points and write to CSV
myTable = formatTableValues(myTable);
writetable(myTable, outputCSVFile,'WriteRowNames',true);

end